package com.wu.llpsw.networking.packet;

import com.wu.llpsw.networking.ModMessage;
import com.wu.llpsw.yuanli.energy.yuanliManager;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraftforge.network.NetworkEvent;
import com.wu.llpsw.data.levelData;

import java.util.Random;
import java.util.function.Supplier;

public class huiFuYuanLi {
    public huiFuYuanLi(){

    }

    public huiFuYuanLi(FriendlyByteBuf buf){

    }

    public void toBytes(FriendlyByteBuf buf){

    }

    public boolean handle(Supplier<NetworkEvent.Context> supplier){
        NetworkEvent.Context context = supplier.get();
        context.enqueueWork(()->{
            ServerPlayer player = context.getSender();
            ServerLevel level = player.getLevel();

            int dengJi=levelData.getLevel(player.experienceLevel);
            Random random = new Random();
            int data=random.nextInt(3) + 1;
            data*=dengJi;
            yuanliManager.use(player,data);
            //ModMessage.sendToPlayer(new backYuanLiMaxPacket(yuanliManager.getMaxYuanLi(player)),player);
            //ModMessage.sendToPlayer(new backYuanLiNowPacket(yuanliManager.getNowYuanLi(player)),player);
        });
        return true;
    }
}
